package com.material.web.controller.buy;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.material.common.annotation.Log;
import com.material.common.core.controller.BaseController;
import com.material.common.core.domain.AjaxResult;
import com.material.common.enums.BusinessType;
import com.material.buy.domain.VipRechargeRecord;
import com.material.buy.service.IVipRechargeRecordService;
import com.material.common.utils.poi.ExcelUtil;
import com.material.common.core.page.TableDataInfo;

/**
 * vip充值记录Controller
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@RestController
@RequestMapping("/buy/record")
public class VipRechargeRecordController extends BaseController
{
    @Autowired
    private IVipRechargeRecordService vipRechargeRecordService;

    /**
     * 查询vip充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('buy:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(VipRechargeRecord vipRechargeRecord)
    {
        startPage();
        List<VipRechargeRecord> list = vipRechargeRecordService.selectVipRechargeRecordList(vipRechargeRecord);
        return getDataTable(list);
    }

    /**
     * 导出vip充值记录列表
     */
    @PreAuthorize("@ss.hasPermi('buy:record:export')")
    @Log(title = "vip充值记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VipRechargeRecord vipRechargeRecord)
    {
        List<VipRechargeRecord> list = vipRechargeRecordService.selectVipRechargeRecordList(vipRechargeRecord);
        ExcelUtil<VipRechargeRecord> util = new ExcelUtil<VipRechargeRecord>(VipRechargeRecord.class);
        util.exportExcel(response, list, "vip充值记录数据");
    }

    /**
     * 获取vip充值记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('buy:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(vipRechargeRecordService.selectVipRechargeRecordById(id));
    }

    /**
     * 新增vip充值记录
     */
    @PreAuthorize("@ss.hasPermi('buy:record:add')")
    @Log(title = "vip充值记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VipRechargeRecord vipRechargeRecord)
    {
        return toAjax(vipRechargeRecordService.insertVipRechargeRecord(vipRechargeRecord));
    }

    /**
     * 修改vip充值记录
     */
    @PreAuthorize("@ss.hasPermi('buy:record:edit')")
    @Log(title = "vip充值记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VipRechargeRecord vipRechargeRecord)
    {
        return toAjax(vipRechargeRecordService.updateVipRechargeRecord(vipRechargeRecord));
    }

    /**
     * 删除vip充值记录
     */
    @PreAuthorize("@ss.hasPermi('buy:record:remove')")
    @Log(title = "vip充值记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vipRechargeRecordService.deleteVipRechargeRecordByIds(ids));
    }
}
